#ifndef _H_APP_
#define _H_APP_
#include "define.h"
#include "fir.h"

#define _CALIBRATION_ (TRUE)
#define AP_MODE_IDLE 0
#define AP_MODE_SCAN 1
#define AP_MODE_FIXEDFREQ 2
#define AP_MODE_DETECT 3
#define APP_START_FREQ 100
#define APP_SCAN_FREQ_GAP 50
#define APP_STOP_FREQ 400000
#define APP_SCAN_FREQ_SIZE (APP_STOP_FREQ / APP_SCAN_FREQ_GAP)

#define APP_SCAN_AMP 2000
#define APP_WAVEDATA_LENGTH 1024
#define APP_FIR_MAXLENGTH 1024
#define APP_FQ_SIZE 512
#define APP_ADC_SIZE 4096
typedef struct{
	U8 mode;
	U8 output;
	U32 freq;
	U16 amp;
	
	
	U8 state;
	U16 timer;
	U32 curfreq;
	U16 scanpointer;
	U16 scansize;
	
	U16 sendpointer;
	float attr;
	float cosphi;
	
	float detfreq;
	float outputfreq;
	U32 samplerate;
	U32 samplesize;
	U16 esamplesize;
	float esamplerate;
	U16 firlength;
	STRZPNodeType zpnodes[APP_FQ_SIZE];
	U16 wavedata[APP_WAVEDATA_LENGTH];
	float firdata[APP_FIR_MAXLENGTH];
	float adcdata[APP_ADC_SIZE];
	float filteradcdata[APP_ADC_SIZE];
}STRAPConType;

#define LED1_GPIO_PORT    	GPIOF
#define LED1_GPIO_CLK 	    RCC_AHB1Periph_GPIOF
#define LED1_GPIO_PIN		9
#define LED1_GPIO_PIN_DEF       GPIO_Pin_9

#define LED2_GPIO_PORT    	GPIOC
#define LED2_GPIO_CLK 	    RCC_AHB1Periph_GPIOC
#define LED2_GPIO_PIN		3
#define LED2_GPIO_PIN_DEF       GPIO_Pin_3

extern STRAPConType g_ap_stRegs;
extern void app_init(void);
extern void app_task(void);
extern void fnAP_GetID(char *msg, U16 *pointer);
#endif
